﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using chessLogic;

namespace chessTest
{
    [TestFixture]
    class testBoard
    {
        private Board board;
        [SetUp]
        public void SetUp()
        {
            board = new Board();
            board.InitialBoard();
        }
        [Test]
        public void testSetFigureOnBoard()
        {
            Position pos = new Position('a',0);
            board.setFigure(pos, new Rook(FigureColor.White));
            Assert.IsInstanceOf(typeof(Rook), board.getFigure(pos));
        }
        [Test]
        public void testInitialGame()
        {
            board.InitialBoard();
            Assert.IsInstanceOf(typeof(Figure), board.getFigure(new Position('a', 3)));
            Assert.IsInstanceOf(typeof(Figure), board.getFigure(new Position('b', 6)));
            Assert.IsInstanceOf(typeof(Figure), board.getFigure(new Position('c', 7)));
        }
        [Test]
        public void testGetTruePosition()
        {
            Assert.True(board.getPosition(0, 0).Equals(new Position("a1")));
        }
        [Test]
        public void testMoveFigure()
        {
            board.MoveFigure(new Position('e', 1), new Position('e', 3));
            Assert.AreEqual(board.getFigure(new Position('e', 1)).Type, new None().Type);
        }
        [Test]
        public void testPositionEmpty()
        {
            Assert.False(board.IsPositionEmpty(board.getPosition(0, 0)));
            Assert.True(board.IsPositionEmpty(new Position("e3")));
        }
        [Test]
        public void testKingPosition()
        {
            Assert.AreEqual(board.getFigurePositions(new King(FigureColor.Black))[0].ToString(), "e8");
            Assert.AreEqual(board.getFigurePositions(new King(FigureColor.White))[0].ToString(), "e1");
        }
        [Test]
        public void testGetFigurePositions()
        {
            Assert.AreEqual(2, board.getFigurePositions(new Bishop(FigureColor.White)).Count);
            Assert.AreEqual(8, board.getFigurePositions(new Pawn(FigureColor.White)).Count);
        }
        [Test]
        public void testSetOldAndNewPositions()
        {
            board.MoveFigure(new Position("e2"), new Position("e3"));
            Assert.AreEqual(board.OldPosition.ToString(), "e2");
            Assert.AreEqual(board.NewPosition.ToString(), "e3");
        }
    }
}
